{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14ce67c3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import k3d\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a26ad80",
   "metadata": {},
   "outputs": [],
   "source": [
    "N = 1000\n",
    "line = k3d.line(np.cumsum(np.random.randn(N,3).astype(np.float32),axis=0), \n",
    "                shader='mesh',\n",
    "                width = 0.2,\n",
    "                custom_data = {\"test\": 123})\n",
    "\n",
    "plot = k3d.plot(custom_data={\"test\": 321})\n",
    "plot += line\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e63e0bc1",
   "metadata": {},
   "outputs": [],
   "source": [
    "code = [\n",
    "    \"console.log(K3DInstance.getWorld().ObjectsListJson[%s].custom_data);\" % (line.id),\n",
    "    \"console.log(K3DInstance.parameters.customData);\"\n",
    "]\n",
    "with open(\"./custom_data.html\", \"w\") as f:\n",
    "    f.write(\n",
    "        plot.get_snapshot(\n",
    "            additional_js_code=\"\\n\".join(code)\n",
    "        )\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99eae867",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
